package com.wss.common.widget;

import ohos.agp.components.AttrSet;
import ohos.agp.components.Component;
import ohos.agp.components.Text;
import ohos.agp.render.Canvas;
import ohos.agp.utils.Rect;
import ohos.app.Context;

/**
 * Describe：带渐变颜色的TextView
 * Created by 吴天强 on 2019/7/1.
 */
public class GradientTextView extends Text implements Component.DrawTask{

    private Rect mTextBound = new Rect();
    private boolean gradient;

    public GradientTextView(Context context) {
        this(context, null);
    }

    public GradientTextView(Context context, AttrSet attrSet) {
        this(context, attrSet, null);
    }

    public GradientTextView(Context context, AttrSet attrSet, String styleName) {
        super(context, attrSet, styleName);
    }

    @Override
    public void onDraw(Component component, Canvas canvas) {
        int mViewWidth = getEstimatedWidth();
        //TODO 绘制渐变色文字
    }

    /**
     * 设置是否渐变
     */
    public void setGradient(boolean gradient) {
        this.gradient = gradient;
        invalidate();
    }
}
